package com.ksyun.campus.client.domain;

import java.util.List;

/**
 * 文件块信息类
 * 用于表示文件系统中块的基本信息和副本分布
 */
public class BlockInfo {
    private String fileId;
    private int blkIdx;
    private long size;
    private List<ReplicaInfo> replicas;
    
    // 默认构造函数
    public BlockInfo() {}
    
    // 带参数构造函数
    public BlockInfo(String fileId, int blkIdx, long size, List<ReplicaInfo> replicas) {
        this.fileId = fileId;
        this.blkIdx = blkIdx;
        this.size = size;
        this.replicas = replicas;
    }
    
    // Getter 和 Setter 方法
    public String getFileId() {
        return fileId;
    }
    
    public void setFileId(String fileId) {
        this.fileId = fileId;
    }
    
    public int getBlkIdx() {
        return blkIdx;
    }
    
    public void setBlkIdx(int blkIdx) {
        this.blkIdx = blkIdx;
    }
    
    public long getSize() {
        return size;
    }
    
    public void setSize(long size) {
        this.size = size;
    }
    
    public List<ReplicaInfo> getReplicas() {
        return replicas;
    }
    
    public void setReplicas(List<ReplicaInfo> replicas) {
        this.replicas = replicas;
    }
    
    @Override
    public String toString() {
        return "BlockInfo{" +
                "fileId='" + fileId + '\'' +
                ", blkIdx=" + blkIdx +
                ", size=" + size +
                ", replicas=" + replicas +
                '}';
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        
        BlockInfo blockInfo = (BlockInfo) o;
        
        if (blkIdx != blockInfo.blkIdx) return false;
        if (size != blockInfo.size) return false;
        if (fileId != null ? !fileId.equals(blockInfo.fileId) : blockInfo.fileId != null) return false;
        return replicas != null ? replicas.equals(blockInfo.replicas) : blockInfo.replicas == null;
    }
    
    @Override
    public int hashCode() {
        int result = fileId != null ? fileId.hashCode() : 0;
        result = 31 * result + blkIdx;
        result = 31 * result + (int) (size ^ (size >>> 32));
        result = 31 * result + (replicas != null ? replicas.hashCode() : 0);
        return result;
    }
}
